
interface MenuItem {
    title: string,
    path: string,
    icon: string,
    children?: Array<MenuItem>

}

export const menuList: Array<MenuItem> = [
    {
        title: '首页',
        path: '/Home',
        icon: 'house',
    },
    {
        title: 'AI',
        path: '/Ai',
        icon: 'edit',
    },
    {
        title: 'Antd',
        path: '/Antd',
        icon: 'edit',
    },
    {
        title: 'WebWoker',
        path: '/WebWoker',
        icon: 'help',
    },
    {
        title: 'UseL7Map',
        path: '/UseL7Map',
        icon: 'location',
    },
    {
        title: '3D城市',
        path: '/ThreeDCity',
        icon: 'OfficeBuilding',

    },
    {
        title: '轨迹飞行',
        path: '/Fly',
        icon: 'Promotion',
    },
    {
        title: '省地图',
        path: '/ProvinceMap',
        icon: 'Location',

    },
    {
        title: '点图层',
        icon: 'Aim',
        path: 'dtc',
        children: [
            {
                path: '/PointCsv',
                title: '点图层_CSV',
                icon: 'location'
            },
            {
                path: '/CityLight',
                title: '城市亮度图',
                icon: 'location'
            }
        ]
    },
    {
        title: '等高线',
        path: '/HighLine',
        icon: 'DataLine',
    },
    {
        title: '海拔线',
        path: '/AltitudeLine',
        icon: 'DataLine',
    },
    {
        title: '风场',
        path: '/Wind',
        icon: 'WindPower',
    },
    {
        title: '图层对比',
        path: '/LayerCompar',
        icon: 'Money',

    },
    {
        title: '地图标记',
        path: '/MapMarker',
        icon: 'AddLocation',
    },
    {
        title: '普通封装MapBox',
        icon: 'user',
        path: 'cd1',
        children: [
            {
                path: '/Gis',
                title: 'Gis',
                icon: 'location'
            },
            {
                path: '/Gis2',
                title: 'Gis2',
                icon: 'location'
            },
            {
                title: 'GIS3',
                path: '/Gis3',
                icon: 'location'
            },
        ]
    },
    {
        title: '插槽',
        path: '/Slot',
        icon: 'edit',

    },
    {
        title: 'L7添加图层',
        path: '/L7AddLayer',
        icon: 'location',

    },
    {
        title: 'L7路径流向',
        path: '/L7Lujing',
        icon: 'location',

    },
    {
        title: 'Ydyl',
        path: '/Ydyl',
        icon: 'location',
    },
]

// 获取所有要导入的文件夹下的组件list
const modules = import.meta.glob('../views/**/*.vue')
// console.log(modules)

// 一级菜单路由
const routesOne = menuList.filter(item => !item.children).map((item: MenuItem) => {
    return {
        path: item.path,
        name: item.title,
        component: modules[`../views${item.path}/index.vue`]
    }
})

// 有子集的二级菜单路由
let routesTwo: any = []
menuList.filter((item: MenuItem) => item.children).forEach((item: MenuItem) => {
    // @ts-ignore
    let res = item?.children.map(c => {
        return {
            path: c.path,
            name: c.title,
            component: modules[`../views${c.path}/index.vue`]
        }
    })
    routesTwo.push(...res)
})


export const routesChild = [
    ...routesOne,
    ...routesTwo,
    {
        path: '/:pathMatch(.*)*',
        name: '404 not-found',
        component: modules[`../views/NotFoundView/index.vue`],
    }
]
